package day7.exception;

import javafx.scene.chart.ScatterChart;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class TestUserNameAreadyUser {

    public static void main(String[] args){

        ArrayList<String> list = new ArrayList<String>();
        list.add("张三");

        System.out.println("请输入你的用户名:");

        String username = "张三";

        try {
            test(username, list);
        } catch (UserNameAreadyUseException e) {
            e.printStackTrace();
        }
    }

    private static void test(String username, List<String> list){

        for (int i = 0; i < list.size(); i++){
            if (username.equals(list.get(i)))
                throw new UserNameAreadyUseException(username + "用户名已被占用");
        }
    }
}
